package com.han.school.controller;
import com.han.school.pojo.User;
import com.han.school.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;

@RestController
public class UserController {


    @Autowired private UserService userService;
    @RequestMapping("/changePassword")
    public String changePassword(String oldpwd , String newpwd , HttpSession httpSession){

        User user = (User)httpSession.getAttribute("user");
        user.setPwd(newpwd);
        int row = userService.changePassword(user);
        if (row>0){
            return "1";
        }
        return  "0";
    }


}
